-- || Created by Revelse

DeathmatchRoom = inherit(Room)
inherit(CustomWeapons, DeathmatchRoom)
inherit(VoteSystem, DeathmatchRoom)

function DeathmatchRoom:constructor()
	Room.constructor(self,GamemodeManager:getSingleton():getGamemodeByName("Deathmatch"))
	CustomWeapons.constructor(self)
	VoteSystem.constructor(self)
	
	self:setMapTag("ffa")
	
	-- CREATE WEAPONS-PATTERN
	self:createWeaponTeam("none")
	self:addWeapon("none", 24, 500)
	self:addWeapon("none", 29, 500)
	self:addWeapon("none", 31, 500)
	self:addWeapon("none", 3, 1)
	
	self:setMinPlayers(2)
	
end

function DeathmatchRoom:onJoin(player)
	self:setPlayerTeam(player,"none")
	
	if self:isVoteEnabled() then
		player:triggerEvent("reciveVoteSystemMaps", self:getGamemodeMaps())
	end
	
	self:spawnPlayer(player)
end

function DeathmatchRoom:spawnPlayer(player)
	local spawnPoint = MapManager:getSingleton():getSpawnpoints(self:getCurrentMap())
	local rnd = math.random(1,#spawnPoint)
	local x,y,z = spawnPoint[rnd].posX,spawnPoint[rnd].posY,spawnPoint[rnd].posZ
	
	player:spawnPlayer(x,y,z)
	self:setWeapons(player,self:getPlayerTeam(player))
	
	setElementInterior(player, spawnPoint[rnd].interior)
	setElementDimension(player,self:getDimension())
end